﻿using JESAI.Redis.Abstracts.Commadns;
using JESAI.Redis.Abstracts.Commands;
using JESAI.Redis.Builders;
using JESAI.Redis.Events;
using JESAI.Redis.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JESAI.Redis.Test
{
    public class TestBase
    {
        protected virtual async Task<IRedisCommand> GetRedisAsync()
        {
            var redisCommand = await RedisCommandBuilderExtension.BuildAsync("127.0.0.1:6379,resp3=true");
            redisCommand.RegisterCommandExecuteEvent(CommandBefore);
            redisCommand.RegisterCommandExecuteEvent(CommandBefore2);
            redisCommand.RegisterCommandExecutedEvent(CommandAfter);
            return redisCommand;
        }

        private void CommandBefore(object? sender, CommandExecuteEventArgs e)
        {
            Console.WriteLine("before");
        }
        private void CommandBefore2(object? sender, CommandExecuteEventArgs e)
        {
            Console.WriteLine("before2");
        }
        private void CommandAfter(object? sender, CommandExecutedEventArgs e)
        {
            Console.WriteLine("after");
        }
    }
}
